package com.hzit.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 作者：李嘉浩
 * 时间：2024-08-23-20:32
 * 功能：
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket docketApiInfo(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("api组")
                .select()
                .paths(Predicates.and(PathSelectors.regex("/api/.*")))
                .build();
    }
    @Bean
    public Docket docketAdminInfo(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(adminInfo())
                .groupName("admin组")
                .select()
                .paths(Predicates.and(PathSelectors.regex("/admin/.*")))
                .build();
    }
    /**
     * 1. 定制后端开发接口信息
     * @return
     */
    private ApiInfo adminInfo() {
        return new ApiInfoBuilder()
                .version("1.0.0")
                .title("后台管理系统-API文档")
                .description("本文档描述了后台管理员系统接口")
                .contact(new Contact("合众后台管理员","http://hzitxx.com","23232448@qq.com"))
                .build();
    }
    /**
     * 1. 定制前端开发接口信息
     * @return
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .version("1.0.0")
                .title("后台管理系统-API文档")
                .description("本文档描述了管理系统接口")
                .contact(new Contact("合众后台普通用户","http://hzitxx.com","23232441@qq.com"))
                .build();
    }
}
